/**
 * 作者:hanbo
 * 日期:2019/1/30 16:13
 * 描述:
 */

ipcRenderer.on('btn-event', (event, arg) => {
    switch (arg) {
        case 0:
            startSelection();
            break;
        case 1:
            endSelection();
            break;
        case 2:
            showInputbox();
            break;
        default:
            break;
    }
});
ipcRenderer.on('down-success', (event, arg,state) => {
    console.log("收到消息");
    totalNumber_++;
    if(totalNumber_==totalNumber){
        setPercentage("100", "下载完成");
        totalNumber=0;
        totalNumber_=0;
        window.setTimeout(function () {
            hideProgress();
        },2000)
    }else {
        let title=arg.join("-");
        let progress=totalNumber_/totalNumber*100;
        switch (state){
            case 0:
                title=title+"下载完成";
                break;
            case 1:
                title=title+"下载失败";
                break;
            case 2:
                title=title+"创建文件夹失败";
                break;
            case 3:
                title=title+"文件已存在";
                break;
            default:break
        }
        setPercentage(progress.toFixed(0), title);
    }
});

function sendDownCmd(coordinates) {
    ipcRenderer.send('downFile', coordinates);
}

/**
 * 通知当前底图的url
 * @param url
 */
function setCurrentUrl(url) {
    ipcRenderer.send('mapUrl', url);
}

function sendError(title,content) {
    ipcRenderer.send('errorMessage', [title,content]);
}

